package com.jooink.experiments.elementalgetusermedia.client;

import com.google.gwt.user.client.ui.Widget;

import elemental.client.Browser;
import elemental.html.SourceElement;
import elemental.html.VideoElement;


//a trivial widget wrapper around a VideoElement with added 
//a couple of useful methods to manipulate sources

public class ElementalVideoWidget extends Widget {

	
	private VideoElement videoElement;
	
	
	public ElementalVideoWidget() {
		videoElement =  Browser.getDocument().createVideoElement() ; 
		setElement(ElementalUtils.castElementToElement(videoElement));
	}
		
	
	public void addSource(String source, String type) {
		
		SourceElement src = Browser.getDocument().createSourceElement();
		src.setType(type);
		src.setSrc(source);
		videoElement.appendChild(src);
	}


	public VideoElement getVideoElement() {
		return videoElement;
	}


	

	
}
